package com.webcamtracker.tracker.example;

import com.webcamtracker.move.tracking.TrackingEvent;
import com.webcamtracker.move.tracking.TrackingEventListener;

import java.io.*;


public class DesktopManagement implements TrackingEventListener {
    public static void main(String[] args) {
        try {

            Runtime.getRuntime().exec("/home/machaval/bin/switchNext.sh");
            Runtime.getRuntime().exec("/home/machaval/bin/switchNext.sh");
            Runtime.getRuntime().exec("/home/machaval/bin/switchNext.sh");
            Runtime.getRuntime().exec("/home/machaval/bin/switchNext.sh");


            final Process process = Runtime.getRuntime().exec("/home/machaval/bin/switchPrev.sh");
            final InputStream outputStream = process.getInputStream();
            final BufferedInputStream bufferedOutputStream = new BufferedInputStream(outputStream);
            final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(bufferedOutputStream));
            final String s = bufferedReader.readLine();
            System.out.println("s = " + s);


        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void trackingEventDispatched(TrackingEvent event) {

    }

    public void switchLeft() {
        try {
            Runtime.getRuntime().exec("/home/machaval/bin/switchNext.sh");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void switchRight() {
        try {
            Runtime.getRuntime().exec("/home/machaval/bin/switchRight.sh");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
